/**
 *  Autor：厉高歌
 */
package com.ymatou.iapi.brand.testcase;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.brand.service.AddProductBrandCall;
import com.ymatou.iapi.brand.service.GetProductBrandListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.utils.YMTDateUtil;

@TestSuite
public class Ts_GetProductBrandList {
	private static String dateformat = "MM-dd HH:mm:ss";
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("添加标准品牌信息");
	}

	@Before
	public void caseUp() {
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(new GetProductBrandListCall().getOpurl());
	}
	
	@After
	public void caseDown() {
		Logger.end();
	}

	/**
	  * 根据标准品牌ID列表查询品牌数据
	*/
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetProductBrandList_001(){
		
		Logger.start(true,"根据标准品牌ID列表查询品牌数据");
		try{
			//指定要修改的参数
			Map<String, Object> mm=new HashMap<String,Object>();
			mm.put("KeyWord", "Lgg");
			mm.put("BrandName", "阿迪达斯"+YMTDateUtil.getSysTime(dateformat));
			mm.put("BrandEnName", "Adidas"+YMTDateUtil.getSysTime(dateformat));
			mm.put("BrandDescription", "这是品牌描述信息"+YMTDateUtil.getSysTime(dateformat));
			mm.put("Operator", "Lgg");
			mm.put("BrandLogoUrl", "http://www.ymatou.com/BrandLogoUrl/"+YMTDateUtil.getSysTime(dateformat)+".jpg");		
			mm.put("BrandBannerUrl", "http://www.ymatou.com/BrandBannerUrl/"+YMTDateUtil.getSysTime(dateformat)+".jpg");	
			//添加一个品牌
			Integer ReturnBrandId=AddProductBrandCall.callAndGetBrandId(mm);
			
			List<Integer> list=new ArrayList<>();
				list.add(ReturnBrandId);
			
			Map<String,Object>mm2=new HashMap<String,Object>();
			mm2.put("BrandIdList", new JSONArray(list));

			JSONObject ret=new GetProductBrandListCall().callAndGetReturnData(mm2);
			//响应断言
			Logger.verifyEquals(200, ret.get("Code"), "返回值为200");
			Logger.verifyEquals("操作成功", ret.get("Msg"), "响应信息返回值Msg为：操作成功");
			JSONObject BrandList0=ret.getJSONObject("Data").getJSONArray("BrandList").getJSONObject(0);
			//返回数据断言
			Logger.verifyEquals(mm.get("KeyWord"), BrandList0.get("KeyWord") , "标准品牌关键字KeyWord，返回数据比对 ");
			Logger.verifyEquals(mm.get("BrandName"), BrandList0.get("BrandName"), "标准品牌中文名sBrand，返回数据比对 ");
			Logger.verifyEquals(mm.get("BrandEnName"), BrandList0.get("BrandEnName"), "标准品牌英文名BrandEnName，返回数据比对 ");
			Logger.verifyEquals(mm.get("BrandDescription"), BrandList0.get("BrandDescription"), "标准品牌描述信息BrandDescription，返回数据比对 ");
			Logger.verifyEquals(mm.get("Operator"), BrandList0.get("AddUser"), "标准品牌操作人Operator，返回数据比对 ");
			Logger.verifyEquals(mm.get("BrandLogoUrl"), BrandList0.get("BrandLogoUrl"), "标准品牌品牌Logo图BrandLogoUrl，返回数据比对 ");
			Logger.verifyEquals(mm.get("BrandBannerUrl"), BrandList0.get("BrandBannerUrl"), "标准品牌品牌Logo图BrandBannerUrl，返回数据比对 ");
			Logger.verifyEquals(0, BrandList0.get("Action"), "标准品牌品牌Action，返回数据比对 ");
		}catch (Exception e){
			Logger.fail(e);
		}
	}
	
}
